-- Copyright (c) 2015,2016 Lucky Byte, Inc.
--
-- Summary : 多渠道终端交易判定模块
--
-- Author  : xiaohu <xiaohu@lucky-byte.com>
-- Since   : 2016.1.6
--
-- History
--  * 2016.01.06 : 创建此文件
--

local _trcode_table = {
    ['01001101'] = '查询',
    ['01001102'] = '联盟积分余额查询',
    ['01001103'] = '增值服务查询',
    ['01006101'] = '预付费卡现金充值',
    ['01006102'] = '预付费卡账户充值',
    ['01006103'] = '预付费卡充值确认',
    ['01008101'] = '预付费卡账户验证',
    ['01102101'] = '消费',
    ['01102102'] = '消费-分期付款',
    ['01102103'] = 'MOTO消费',
    ['01102104'] = '联盟积分消费',
    ['01102105'] = '预约消费',
    ['01102106'] = '消费-发积分卡',
    ['01102107'] = '增值服务消费',
    ['01102108'] = '实时送分',
    ['01103101'] = '预授权',
    ['01103102'] = '预授权完成请求',
    ['01103103'] = 'MOTO预授权',
    ['01103104'] = 'MOTO预授权完成请求',
    ['01104101'] = '消费撤销',
    ['01104102'] = '预授权撤销',
    ['01104103'] = '预授权完成请求撤销',
    ['01104104'] = '电子现金现金充值撤销',
    ['01104105'] = '消费撤销-分期付款',
    ['01104106'] = 'MOTO消费撤销',
    ['01104107'] = 'MOTO预授权完成撤销',
    ['01104108'] = 'MOTO预授权撤销',
    ['01104109'] = '联盟积分消费撤销',
    ['01104110'] = '预约消费撤销',
    ['01104111'] = '消费撤销-发积分卡',
    ['01104112'] = '增值服务消费撤销',
    ['01106101'] = '电子现金非指定账户圈存',
    ['01106102'] = '电子现金指定账户圈存',
    ['01106103'] = '电子现金现金充值',
    ['01108101'] = '助农取款',
    ['02003101'] = '预授权完成通知',
    ['02003102'] = 'MOTO预授权完成通知',
    ['02004101'] = '退货',
    ['02004102'] = '脱机消费退货',
    ['02004103'] = 'MOTO退货',
    ['02004401'] = '冲正',
    ['02005101'] = '批上送通知交易',
    ['02007401'] = 'IC卡脚本处理结果通知',
    ['02007402'] = '非指定账户圈存脚本处理结果通知',
    ['03002101'] = '电子现金脱机消费',
    ['03002102'] = '结算调整-金额调整',
    ['03002103'] = '结算调整-小费',
    ['03003101'] = '离线结算-POS预授权',
    ['03003102'] = '离线结算-电话授权',
    ['03003103'] = '离线结算-代授权',
    ['04005101'] = '签到',
    ['04005102'] = '签退',
    ['04005103'] = '批结算',
    ['04005104'] = '收银员签到',
    ['04005301'] = '参数下载',
    ['04005302'] = 'POS状态上送',
    ['04005401'] = '下载结束',
    ['04005402'] = '回响',
    ['04005403'] = 'IC卡批上送通知交易',
    ['01005401'] = '电子凭条',
    ['02004104'] = '分期付款退货',
    ['01108102'] = '建立委托关系',
    ['01108104'] = '撤销委托关系',
    ['01008103'] = '取消所有委托关系',
    ['01181005'] = '建立终端转账委托关系',
    ['01181006'] = '建立终端定制关系',
    ['01181007'] = '撤销终端转账委托关系',
    ['01181008'] = '撤销终端定制关系',
    ['01001106'] = '委托关系查询',
    ['01001104'] = '账单费用查询',
    ['01001105'] = '行业信息查询',
    ['01102109'] = '缴费',
    ['01104113'] = '缴费撤销',
    ['02004106'] = '缴费退货',
    ['01102110'] = '多渠道消费',
    ['01104114'] = '多渠道消费撤销',
    ['02004105'] = '多渠道消费退货',
    ['01102111'] = '单笔代收',
    ['01104115'] = '单笔代收撤销',
    ['01002101'] = '实时代付',
    ['02002401'] = '代付确认',
    ['01006104'] = '委托终端转账',
    ['01006105'] = '卡卡转账',
    ['02004402'] = '冲正交易-多渠道',
}

lib096.trinfo = function(packet)
    assert(packet._class == 'Packet096', string.format(
        'lib096.trinfo() 需要 Packet096 报文，当前报文类型为[%s]', packet._class))

    local _proc_code = packet.get('ff9000')
    if not _proc_code then
        logger.error('获取报文交易类型错误，报文缺少字段[ff9000].')
        return {
            code = 'ttt', name = '未知交易'
        }
    end
    return _trcode_table[_proc_code] or {
        code = 'ttt', name = '未知交易'
    }
end
